from datetime import datetime, timedelta
import jwt
# from django.conf import settings

class JWTTool:

    #参数 userid
    def get_token(self,userid):
        #需要一个过期时间 为1天
        exp = datetime.utcnow() + timedelta(days=1)
        payload = {
            "userid":userid,
            "exp":exp
        }
        key="123"
        return jwt.encode(key=key, payload=payload, algorithm="HS256")
#拿到类的实例
tool=JWTTool()
# print(tool.get_token(1))